select DS_FUNKCE.dbo.Wkt2GdoBlob (
'POLYGON(('
+ CAST(geometry_xlo as varchar(100)) + ' ' + CAST(geometry_ylo as varchar(100))
+ ',' + CAST(geometry_xhi as varchar(100)) + ' ' + CAST(geometry_ylo as varchar(100))
+ ',' + CAST(geometry_xhi as varchar(100)) + ' ' + CAST(geometry_yhi as varchar(100))
+ ',' + CAST(geometry_xlo as varchar(100)) + ' ' + CAST(geometry_yhi as varchar(100))
+ ',' + CAST(geometry_xlo as varchar(100)) + ' ' + CAST(geometry_ylo as varchar(100))
+'))'
) as geometry
,ORP
,geometry_xlo, geometry_ylo, geometry_xhi, geometry_yhi
from(
	select 
	min(geometry_xlo) as geometry_xlo, min(geometry_ylo) as geometry_ylo
	,max(geometry_xhi) as geometry_xhi, max(geometry_yhi) as geometry_yhi
	,LEFT(HONITBA,6) as ORP
	from MZE_MYSL..F_A_HONITBY
	group by LEFT(HONITBA,6)
)t

--exec DS_FUNKCE.dbo.PreferedWKTParser 'HighPerformance'